// Javascript functions for accounts component

function SetId(idnumber,formfield,spanname,username) 
{
 document.getElementById(formfield).value = idnumber;
 document.getElementById(spanname).innerHTML = username;
 $('#dialog2').dialog('close'); 
}

function confirmdeleteaccount(id,urlstring) {
	var agree=confirm("Are you sure you want to delete this account?  This cannot be undone!");
	if (agree)
		location.replace('index.cfm?c=accounts&a=delete&id='+id+urlstring); 
	else
		return false ;
}

function userselect() {
	$('#dialog2').dialog({autoOpen: false, height: 475, width: 900, modal: true, position: "center", dialogClass: 'selection_dialog', title: 'Select User'});
	$('#dialog2').dialog('open');
}

function avatarselect() {
	$('#dialog').dialog({autoOpen: false, height: 475, width: 900, modal: true, position: "center", dialogClass: 'selection_dialog', title: 'Select Avatar'});
	$('#dialog').dialog('open');
}

function viewfieldlist() {
	$('#dialog3').dialog({autoOpen: false, height: 475, width: 300, modal: false, position: ['right','top'], dialogClass: 'default', title: 'Field Names'});
	$('#dialog3').dialog('open');
}

function selectimage(imagefile) {
	document.getElementById('avatarimg').src = imagefile;
	document.getElementById('avatar').value = imagefile;
	$('#dialog').dialog('close');
}

function ConfirmDeleteDownload(dir,FileName){
	var agree=confirm("Are you sure you want to delete this file?");
	if (agree)
	location.replace('index.cfm?c=accounts&a=deletefile&FileName='+FileName+'&dir='+dir); 
	else
	return false ;
}

function ConfirmDeleteDownloadsFolder(dir,FolderName){
	var agree=confirm("Are you sure you want to delete '" + FolderName + "' and everything in it!?");
	if (agree)
	location.replace('index.cfm?c=accounts&a=deletefolder&showfolders=1&FolderName='+FolderName+'&dir='+dir); 
	else
	return false ;
}

function activate(rid, divid) {
	navURL = 'dialogs/accounts/activate.cfm?id='+rid;
	ColdFusion.navigate(navURL, divid);
}

function deactivate(rid, divid) {
	navURL = 'dialogs/accounts/deactivate.cfm?id='+rid;
	ColdFusion.navigate(navURL, divid);
}